﻿/**************************************************************************
创建时间:	2020/5/15 16:20:59    
作	  者:	张存
邮 	  箱:	zhangcunliang@126.com

Copyright (c) zhcun.cn

描	述：
记	录：
***************************************************************************/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ZhCun.Utils;
using ZhCun.Win.Controls;

namespace ZhCun.Win
{
    public partial class FrmSelectTree : FrmBaseModal
    {
        public FrmSelectTree()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 初始化treeview的方法
        /// </summary>
        public Action<TreeViewEx> InitTreeHandle;
        /// <summary>
        /// 选中后触发
        /// </summary>
        public Func<TreeViewEx, ApiResult> OnSelected;

        private void FrmSelectTree_Load(object sender, EventArgs e)
        {
            InitTreeHandle(tv);
        }

        private void tsBtnSelected_Click(object sender, EventArgs e)
        {
            var r = OnSelected(tv);
            if (!r)
            {
                ShowMessage(r.msg);
                return;
            }
            this.DialogResult = DialogResult.OK;
        }

        private void tsBtnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void tv_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (!tv.CheckBoxes) tsBtnSelected_Click(sender, e);
        }
    }
}